from django.conf.urls import url

from booktest import views
from booktest.views import BookInfoListView, BookDetailView, Abc01View, BookInfoListAPIView, BookInfoListGenericAPIView, \
    BookInfoDetailGenericAPIView, BookInfoViewSet, BookInfoGenericViewSet


urlpatterns = [
    # path('admin/', admin.site.urls),
    # 【查询所有】与【新增】公用同一个路由配置
    # url(r'^books/$', BookInfoListView.as_view()),
    # url(r'^books/(?P<pk>\d+)/$', BookDetailView.as_view()),




    url(r'^abc01/$', Abc01View.as_view()),






    # url(r'^books/$', BookInfoListAPIView.as_view()),
    # 使用 GenericAPIView 来编写列表视图
    # url(r'^books/$', BookInfoListGenericAPIView.as_view()),
    # url(r'^books/(?P<pk>\d+)/$', BookInfoDetailGenericAPIView.as_view()),

    # 使用 ViewSet 来实现两个查询接口
    # url(r'^books/$', BookInfoViewSet.as_view({'get' : 'list'})),
    # url(r'^books/(?P<pk>\d+)/$', BookInfoViewSet.as_view({'get' : 'retrieve'})),


    # 使用 GenericViewSet 来实现两个查询接口
    # url(r'^books/$', BookInfoGenericViewSet.as_view({'get' : 'list'})),
    # url(r'^books/latest/$', BookInfoGenericViewSet.as_view({'get' : 'latest'})),
    # url(r'^books/(?P<pk>\d+)/$', BookInfoGenericViewSet.as_view({'get' : 'retrieve'})),


]

from rest_framework import routers

router = routers.DefaultRouter()
router.register(r'books', BookInfoGenericViewSet, 'book')

# 添加到路由中
urlpatterns += router.urls
